﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace HdipCricketClub.Models
{
    public class MemberRepository
    {
        CricketClubEntities db = new CricketClubEntities();

        public Member GetMember(int id)
        {
            return db.Members.SingleOrDefault(m => m.member_id == id);
        }

        public IQueryable<Member> FindAllMembers()
        {
            return db.Members.Include("Club").Include("County1").OrderBy(m => m.last_name);
        }

        public Member GetPlayer(int id)
        {
            return db.Members.SingleOrDefault(m => m.member_id == id && m.playing_member == true);
        }
        
        public IQueryable<Member> FindAllPlayers()
        {
            return db.Members.Include("Club").Include("County1").Where(p => p.playing_member == true).OrderBy(p => p.last_name);
        }

        


    }
}